===== Página de Ajuda =====


R Documentation

**cut_raster()**


====Extraction of specific area from the RasterLayer (Bioclimatic variables)====


**Description**

cut_raster extract a specific area of the RasterLayer (Bioclimatic variables) downloaded from Worldclim. See Note 
(Packages needed to manipulate geographic data). 

**Usage**

lapply(X, cut_raster)
The function cut_rasteris applied to objects RasterLayer (X), thereby requiring the function lapply to be executed 
(see Note).

cut_raster =function(x) 
{ 
function instructions
return (results)
}

**Arguments**

 x	any R object.

**Details**

The purpose of this function is to extract a specific area of the RasterLayer (Bioclimatic variables) downloaded from 
Worldclim (Hijmans et al. 2005). The RasterLayer obtained from Worldclim (bioclimatic variables) are for particular 
areas (Hijmans et al. 2005), which must be adjusted according to the area of interest that will be used in ecological 
niche modeling (Warren and Stephanie 2011). One way to do this procedure is to extract the area of interest one by 
one in the 19-bioclimatic variables. In addition is necessary also to modify the resolution of each RasterLayer 
obtained in the cut. Finally it is also necessary export each new RasterLayer to a specific format, because all 
environmental layers must be in ASCII format to run MaxEnt (Young 2011). 

The function cut_raster performed these three procedures simultaneously on RasterLayer (Bioclimatic variables),
according to the supplied specifications (size of area, resolution and format). 

**Value**

RasterLayer

**Note**

===Packages needed to manipulate geographic data===

1.	[[http://cran.r-project.org/web/packages/raster/index.html|raster]]: Reading, writing, manipulating, analyzing and modeling of gridded spatial data 


2.	[[http://cran.r-project.org/web/packages/maptools/index.html|maptools]]: Set of tools for manipulating and reading geographic data 

3.	[[http://cran.r-project.org/web/packages/rgeos/index.html|rgeos]]: Used to tackle problems with several variables defined in a space of any dimensions 


4.	[[http://cran.r-project.org/web/packages/rgdal/index.html|rgdal]]: It is a translator library for raster and vector geospatial data formats that is released under an X/MIT style Open Source license by the Open Source Geospatial Foundation 


===lapply===

The function lapply (X, FUN) returns a list of the same length as X (RasterLayer), each element of which is the result 
of applying the function (cut_raster) to the corresponding element of X (RasterLayer). More details:
[[http://127.0.0.1:11608/library/base/html/lapply.html|lapply]]. 

**Examples**

===Input files in directory:=== 

1. **RasterLayer of bioclimatic variables of South America** (see file: Annual Mean Temperature in South America.asc).

2. **Shapefile of area to be extracted in each RasterLayer of South America** (see file: shape_brazil). 

===Load the input files===

**list_RasterLayer=list.files("/name directory", pattern=".asc")**

## List elements with asc. format (RasterLayer) found in the directory

**shape=readShapePoly(file.choose())**

##Interactively window for choose data from a polygon shapefile (Shapefile)

**plot(shape)**

##Verify that the shapefile was loaded


**cut_raster =function(x)** 
{ 
**rasters=raster(x)**
**cut=mask(rasters,shape)**
**raster_final=aggregate(cut, fact=10)**
**writeRaster(raster_final, filename=paste(rasters@data@names,"BRAZIL",".asc", sep=""), format="ascii")**
}

**lapply(list_RasterLayer, cut_raster)**

### The function lapply applies the function cut_raster on each RasterLayer present in the list_RasterLayer. It takes some minutes per each RasterLayer.


**References**

Warren, D.L. S. N. Seifert. 2011. Ecological niche modeling in Maxent: the importance of model complexity and the 
performance of model selection criteria. Ecological Applications 21(2): 335-342

Hijmans, R.J., S.E. Cameron, J.L. Parra, P.G. Jones and A. Jarvis, 2005. Very high resolution interpolated climate 
surfaces for global land areas. International Journal of Climatology 25: 1965-1978.

Young, N. 2011. A MaxEnt Model v3.3.3e Tutorial (ArcGIS v10). 
[[http://ibis.colostate.edu/WebContent/WS/ColoradoView/TutorialsDownloads/A_Maxent_Model_v7.pdf|Tutorial]].
